home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: Pointers to structures question.
- Date: 25 Mar 1996 11:28:49 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4j601h$btp@sparcserver.lrz-muenchen.de>
- References: <4j2drs$q3r@dfw-ixnews3.ix.netcom.com> <3154F14C.35ED@ix.netcom.com>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- Brian Land <bland@ix.netcom.com> writes:
-
- >Andrew Heiz wrote:
- >>
- >> Hi there,
- >>
- >> Thanks for reading.
- >>
- >> I have a simple question about using pointers to structures. I am
- >> imputing data into a structure using:
- >>
- >> gets(struct.element);
- >>
- >> My question is in how to reference the structure element with a
- >> pointer. How do I do this?
- >>
-
-
- >How about....
-
- > gets( &(struct.element) );
-
- If "struct.element" is something that is worth being passed to gets()
- - or fgets() for programmers who want to get input from anything but
- another program with well-defined behaviour - then "gets(struct.element)"
- passes a pointer to char whereas "gets(&struct.element)" passes either a
- pointer to an array of char or a pointer to a pointer to char. Check what
- _your_ gets() expects. If it does not expect a pointer to char, talk to
- the vendor of your standard C library.
-
- Andrew's question cannot be answered without assuming something about
- what he is talking about. It is hard but not impossible to think of
- a situation where the "&" operator might be necessary.
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
- | ua302aa@sunmail.lrz-muenchen.de
-